package cn.iocoder.yudao.module.api.brokerage.record.enums;

import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.business.basic.enums.EnumCodable;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * 佣金记录业务类型枚举
 *
 * @author owen
 */
@RequiredArgsConstructor
@Getter
public enum BrokerageRecordBizTypeEnum implements EnumCodable {

    UNKNOWN("undefined", "未知分佣", "未知的分佣场景，推广人获得%s佣金 ¥%s"),
    OFFLINE_SCAN_ORDER("offline_scan_order", "扫码付款分佣", "用户扫商家收款码付款后，推广人获得%s佣金 ¥%s"),
    BUY_PRODUCT("buy_product", "购买产品分佣", "用户购买产品后，推广人获得%s佣金 ¥%s"),
    BUY_VIP("buy_vip", "购买会员分佣", "用户购买会员后，推广人获得%s佣金 ¥%s"),
    BUY_AGENCY("buy_agency", "缴费分佣", "招商人员缴纳年费后，推广人获得%s佣金 ¥%s"),
    SHOP_INCOME("shop_income", "营业收入分佣", "商家营业收入进账后，招商人员获得%s佣金 ¥%s"),
    ;

    @EnumValue
    private final String code;
    private final String name;
    private final String summary;

    public static BrokerageRecordBizTypeEnum codeOf(String code) {
        for (BrokerageRecordBizTypeEnum item : values()) {
            if (StrUtil.equalsIgnoreCase(item.getCode(), code)) {
                return item;
            }
        }
        return UNKNOWN;
    }

}
